Skip to content

RM-254: Refactor permission checks for thread/channel modes#134

Open
biast12 wants to merge 10 commits into
masterfrom
RM-254
Open

RM-254: Refactor permission checks for thread/channel modes#134
biast12 wants to merge 10 commits into
masterfrom
RM-254

Conversation

@biast12

@biast12 biast12 commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

Description

Make permission checking mode-aware and group missing perms by location.

  • Adjust server-wide permission list to depend on settings.UseThreads to avoid reporting irrelevant missing permissions. Append standard permissions after mode-specific ones.
  • In panel permission checks, treat a panel as using threads if either global settings or the panel enable threads. Use logic.ThreadPermissions for thread-mode channel checks and simplify assembled permission slices.
  • Add ThreadPermissions constant in bot/logic/discordpermissions.go for reuse.
  • Rewrite findMissingPermissions to return labeled missing-permission groups (panel channel, notification channel, transcript channel) instead of a flat list; check primary channel, optional notification channel (thread mode), and transcript channel, using channel-level and guild-level checks as appropriate.
  • Update reply formatting to render missing permissions grouped by location with a title and footer linking docs.

These changes reduce false positives, centralize thread-mode permissions, and provide clearer error messages to users about where permissions are missing.

Needs: TicketsBot-cloud/common#5

image

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Improvement

Testing

  • Remove all the permissions from the bot and channels / categories that it uses (it should still have manage roles globally)
  • Then try to open a ticket with each mode
  • Play around with the permissions and see how they react

Checklist

  • My code follows the style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Make permission checking mode-aware and group missing perms by location.

- Adjust server-wide permission list to depend on settings.UseThreads to avoid reporting irrelevant missing permissions. Append standard permissions after mode-specific ones.
- In panel permission checks, treat a panel as using threads if either global settings or the panel enable threads. Use logic.ThreadPermissions for thread-mode channel checks and simplify assembled permission slices.
- Add ThreadPermissions constant in bot/logic/discordpermissions.go for reuse.
- Rewrite findMissingPermissions to return labeled missing-permission groups (panel channel, notification channel, transcript channel) instead of a flat list; check primary channel, optional notification channel (thread mode), and transcript channel, using channel-level and guild-level checks as appropriate.
- Update reply formatting to render missing permissions grouped by location with a title and footer linking docs.

These changes reduce false positives, centralize thread-mode permissions, and provide clearer error messages to users about where permissions are missing.
biast12 added 4 commits April 12, 2026 12:48
Replace local permission constants/usages with the centralized github.com/TicketsBot-cloud/common/botpermissions package across the codebase. Updated imports and calls to BuildPermissions to use botpermissions.StandardPermissions, MinimalPermissions, ThreadModeRequired, NotifChannelRequired, TranscriptChannelRequired, and ChannelModeRequired where appropriate. Removed duplicate permission arrays from bot/logic/discordpermissions.go and adjusted code to copy/append permission slices safely. Also enabled a local replace for the common module in go.mod. This centralizes permission definitions and reduces duplication.
Replace manual permission aggregation with botpermissions.EffectivePermissions and consolidate data fetching into fetchGuildData/fetchChannelData/buildRoleMap helpers. Simplifies HasPermissions/HasPermissionsChannel and GetMissingPermissions* by delegating to centralized logic, removes many in-file permission helpers, and updates imports accordingly. Keeps existing error handling (sentry) and preserves administrator short-circuit behavior.
@github-actions github-actions Bot added the needs:bump_common PR references common repo changes label Apr 25, 2026
Uncomment the replace directive for github.com/TicketsBot-cloud/common in go.mod to point to the local ../common module. This allows building and testing against the local copy of the common package during development; other replace directives remain unchanged.
@github-actions github-actions Bot added the needs:gomod_comment go.mod has uncommented local replace directives label Apr 25, 2026
BenHall-1
BenHall-1 previously approved these changes Apr 26, 2026
@BenHall-1

Copy link
Copy Markdown
Member

@biast12 good to bump when you are

@github-actions github-actions Bot removed the needs:gomod_comment go.mod has uncommented local replace directives label Apr 26, 2026
@biast12 biast12 removed the needs:bump_common PR references common repo changes label Apr 26, 2026
@biast12

biast12 commented Apr 26, 2026

Copy link
Copy Markdown
Contributor Author

bumped!

@github-actions github-actions Bot added the needs:bump_common PR references common repo changes label Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:bump_common PR references common repo changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants